﻿using Sidvall.Data;
using Sidvall.Net;
using Sidvall.Security;

namespace Sidvall.DataPortal
{
    public class ServerConnection
    {
        #region Public Members

        public ConnectionType ConnectionTypeId { get; set; }
        public string ConnectionString { get; set; }
        public string Description { get; set; }
        public string RemoteAddress { get; set; }
        public string Key { get; set; }
        public TransactionSettings TransactionSettings { get; set; }
        public IAuthenticationStrategy AuthenticationStrategy { get; set; }
        public IStorageManagerFactory StorageManagerFactory { get; set; }

        #region RunLocal

        public bool RunLocal
        {
            get
            {
                switch (this.ConnectionTypeId)
                {
                    case ConnectionType.RemoteAccess:
                        return false;
                    default:
                        return true;
                }
            }
        }

        #endregion
        #region TransactionScopeFactory

        private ITransactionScopeFactory _TransactionScopeFactory;
        public ITransactionScopeFactory TransactionScopeFactory
        {
            get
            {
                if (_TransactionScopeFactory != null)
                    return _TransactionScopeFactory;
                return Sidvall.SystemContext.Current.TransactionScopeFactory;
            }
            set
            {
                _TransactionScopeFactory = value;
            }
        }

        #endregion
        #region HttpClientFactory

        private IHttpClientFactory _HttpClientFactory;
        public IHttpClientFactory HttpClientFactory
        {
            get
            {
                if (_HttpClientFactory != null)
                    return _HttpClientFactory;
                return Sidvall.SystemContext.Current.HttpClientFactory;
            }
            set
            {
                _HttpClientFactory = value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public ServerConnection()
        {
        }

        #endregion
    }
}
